package com.robot.coupon.dao;

import com.robot.coupon.pojo.Coupon;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

/**
 * coupon数据访问接口
 *
 * @author wuyunbin
 */
public interface CouponDao extends JpaRepository<Coupon, String>, JpaSpecificationExecutor<Coupon> {
    /**
     * 根据会员ID查找该会员名下的所有优惠券
     *
     * @param memberId
     * @param pageable
     * @return
     */
    Page<Coupon> findAllByMemberId(String memberId, Pageable pageable);

    /**
     * 根据会员ID查找该会员名下特定状态的所有优惠券
     *
     * @param memberId
     * @param status
     * @param pageable
     * @return
     */
    Page<Coupon> findAllByMemberIdAndStatus(String memberId, String status, Pageable pageable);

    /**
     * 根据会员ID查找该会员名下的某张优惠券
     *
     * @param id
     * @param memberId
     * @return
     */
    Coupon findByIdAndMemberId(String id, String memberId);

}
